package com.wayhome.srpingbootmybatis.async;


public interface TaskListener {

    void beforeExecute(TaskExecutionContext taskContext);

    void afterSetRunning(TaskExecutionContext taskContext);

    void afterExecute(TaskExecutionContext taskContext, Throwable ex);

    class TaskExecutionContext {
        private String type;
        private ChannelMessage message;
        private Object parameter;
        private boolean firstRunning = false;

        public String getType() {
            return type;
        }
        public static TaskExecutionContext newInstance() {
            return new TaskExecutionContext();
        }

        public TaskExecutionContext setType(String type) {
            this.type = type;
            return this;
        }

        public ChannelMessage getMessage() {
            return message;
        }

        public TaskExecutionContext setMessage(ChannelMessage message) {
            this.message = message;
            return this;
        }

        public Object getParameter() {
            return parameter;
        }

        public TaskExecutionContext setParameter(Object parameter) {
            this.parameter = parameter;
            return this;
        }

        public boolean isFirstRunning() {
            return firstRunning;
        }

        public TaskExecutionContext setFirstRunning(boolean firstRunning) {
            this.firstRunning = firstRunning;
            return this;
        }
    }


}
